package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.ClientBean;
import com.project.service.IClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("client")
public class ClientController {
    @Autowired
    private IClientService service;

    @RequestMapping("findByItem")
    public IPage<ClientBean> findByItem(Integer pageNO, String name, String ranges) {
        return service.findByItem(pageNO,name, ranges);
    }

    @RequestMapping("findById")
    public ClientBean findById(Integer clientId) {
        return service.findById(clientId);
    }
    @RequestMapping("addClient")
    public String addClient(ClientBean client) {
        return service.addClient(client);
    }
    @RequestMapping("updateClient")
    public String updateClient(Integer clientId, String headerName, String headerPhone, String range) {
        service.updateClient(clientId,headerName, headerPhone, range);
        return "ok";
    }
    @RequestMapping("findAll")
    public List<ClientBean> findAll() {
        return service.findAll();
    }

    @RequestMapping("findByName")
    public ClientBean findByName(String name) {
        return service.findByName(name);
    }


}
